import {createRouter, createWebHistory} from 'vue-router'
import HomeView from '../views/HomeView.vue'

const routes = [
    {
        path: '/',
        name: 'home',
        component: HomeView,
        redirect:'/index',  /*重定向*/
        children: [
            {
                path: '/index',
                component: () => import('../views/home/IndexView')
            },{
                path: '/detail',
                component: () => import('../views/home/DetailView')
            },{
                path: '/reg',
                component: () => import('../views/home/RegView')
            },{
                path: '/login',
                component: () => import('../views/home/LoginView')
            }
        ]
    },
    {
        path: '/admin',
        component: () => import('../views/AdminView.vue'),
        redirect: '/admin/category',
        children: [
            {  //   /admin/category
                path: 'category',
                component: () => import('../views/admin/CategoryView'),
            },
            {
                path: 'banner',
                component: () => import('../views/admin/BannerView'),
            },
            {
                path: 'product',
                component: () => import('../views/admin/ProductView'),
            }
        ]
    }
]

const router = createRouter({
    history: createWebHistory(process.env.BASE_URL),
    routes
})

export default router
